package com.pty.demo.behaviour.iterator;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * @author pengty
 * @date 2020/3/14
 */
public class CustomAggregate implements AbstractAggregate {

    private List<Object> list;

    public CustomAggregate() {
        this.list = Lists.newArrayList();
    }

    @Override
    public void add(Object object) {
        list.add(object);
    }

    @Override
    public void remove(Object object) {
        list.remove(object);
    }

    @Override
    public Iterator getIterator() {
        return new CustomIteratorImpl(list);
    }
}
